package tools

type TreeAble interface {
	GetPid() int64
	GetId() int64
	AddChildren([]TreeAble)
}

func TreeData(lists []TreeAble, pid int64) []TreeAble {
	result := make([]TreeAble, 0)
	for _, v := range lists {
		if v.GetPid() == pid {
			v.AddChildren(TreeData(lists, v.GetId()))
			result = append(result, v)
		}
	}
	return result
}
